﻿using System;
using System.Runtime.InteropServices;
namespace DailyNote
{
    public class DateHelper
    {
        /// <summary>
        /// 判断闰年
        /// </summary>
        /// <param name="year">年份</param>
        /// <returns>是否闰年</returns>
        static bool Isleap(int year)
        {
            return year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
        }
        /// <summary>
        /// 计算当月的天数
        /// </summary>
        /// <param name="month">月份</param>
        /// <param name="b">是否闰年</param>
        /// <returns>当月的天数</returns>
        static int Nummonth(int month, bool b)
        {
            int num;
            if (month == 2 && b)
            {
                num = 29;
            }
            else
            {
                if (month == 2 && !b)
                {
                    num = 28;
                }
                else
                {
                    if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
                    {
                        num = 31;
                    }
                    else
                    {
                        num = 30;
                    }
                }
            }
            return num;
        }
    }
}

